﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace Steve.UI.Administration.DataAnnotations
{
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
    public sealed class AbsoluteUriAttribute : ValidationAttribute
    {
        public AbsoluteUriAttribute() : base("{0} is not a valid absolute uri (must contain scheme, authority and path).")
        {
        }

        public override bool IsValid(object value)
        {
            var uri = value as Uri;

            if (uri != null && uri.IsAbsoluteUri) return true;

            return false;
        }
    }
}
